www.gusucode.com > VC++ 十进制的圆面积计算器源代码-源码程序 > VC++ 十进制的圆面积计算器源代码-源码程序/code/MainDlg.cpp
#include "stdafx.h" #include <windows.h> #include <windowsx.h> #include "resource.h" #include "MainDlg.h" const double PI=3.14159265; // Download by http://www.NewXing.com BOOL WINAPI Main_Proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch(uMsg) { HANDLE_MSG(hWnd, WM_INITDIALOG, Main_OnInitDialog); HANDLE_MSG(hWnd, WM_COMMAND, Main_OnCommand); HANDLE_MSG(hWnd,WM_CLOSE, Main_OnClose); } return FALSE; } BOOL Main_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam) { return TRUE; } void Main_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify) { switch(id) { TCHAR str1[256],str2[256]; case IDC_BUTTON1: { GetDlgItemText(hwnd,IDC_EDIT1,str1,sizeof(str1)); double f1=atof(str1); double area=PI*f1*f1; int s=area; wsprintf(str2,"%d",s); SetDlgItemText(hwnd,IDC_EDIT2,str2); } break; default: break; } } void Main_OnClose(HWND hwnd) { EndDialog(hwnd, 0); }